
<%@ page import="java.util.*"%>
<%@ page import="Domain.DataManager"%>
<%@ page import="Domain.UserClient.ButtonsFunctions"%>
<%@ page import="Domain.UserClient.SocketListener"%>
<%@ page import="Domain.stompProtocol.StompClient"%>
<%@ page import="javax.annotation.PreDestroy"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%
	if (session.isNew() || session.getAttribute("dm") == null) {
		
		session.setMaxInactiveInterval(1000000000);
		
		StompClient stompClient = null;
		DataManager dm = null;
		ButtonsFunctions bf = null;
		SocketListener socketList = null;

		try {
			stompClient = new StompClient("localhost", 61635);
		} catch (Exception ex) {
			System.out.println("can't connect to the stomp server!");
			System.exit(0);
		}
		dm = new DataManager();
		bf = new ButtonsFunctions(stompClient, dm);
		socketList = new SocketListener(bf, dm, stompClient);
		Thread t = new Thread(socketList);
		t.start();
		System.out.println("One client has been initiated!");

		session.setAttribute("dm", dm);
		session.setAttribute("stCli", stompClient);
		session.setAttribute("bf", bf);
		session.setAttribute("sockList", t);
	}
%>
<%
	DataManager dm = (DataManager) (session.getAttribute("dm"));
	if (dm.getUserStatus() == DataManager.CONNECTED) {
		response.sendRedirect("ChooseForum.jsp");
	} else {
%>

<%
	dm.setCurrForum(null);
	dm.setCurrThread(null);
	dm.setCurrUser("");
%>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">

<!---the title of the page-->
<title>Login Page</title>

</head>

<body>

	<table width="100%" height="100%" border="1" cellspacing="0"
		cellpadding="0">

		<!-- HEADER -->
		<tr class="header">
			<td>
				<!-- cool navigation toolbar code -->
				<ul id="navlist">
					<!--<li id="prev"><a href=""></a></li>
					 <li id="notifications"><a href="ChooseForum.jsp"></a></li> 
					<li id="connection">Connected as: <b><i><font
								color='#FF0000'></font> </i> </b></li>-->
				</ul>
			</td>
		</tr>

		<!-- BODY -->
		<tr class="body">
			<td class="forumBody">
				<center>
					<h6>
						<font color="#FFF11" size="7"><i>Welcome To Our Forum</i> </font>
					</h6>
				</center>

				<FORM METHOD=POST ACTION="CheckLogin.jsp">
					<div align="center">
						<br> <br> <br> <b><font color="yellow">
								What's your Username?</font> </b> <INPUT TYPE=TEXT NAME='username' SIZE=20
							value=""><BR> <br> <b><font color="yellow">
								What's your Password? <INPUT TYPE=password NAME='password'
								SIZE=20 value=""> </font> </b> <br> <br> <b></b> <b>
							<a href="Register.jsp"><font size=3 color="#CCFFFF">create
									new account</font>
						</a> </b> <br>

						<P>
							<input type="submit" name="login" value="login" />
						</P>
					</div>
				</FORM></td>
		</tr>
	</table>
</body>

</html>

<%
	}
%>




